/**
 * Created by Administrator on 2019/4/3.
 */
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'order/tcorder/index',
                    edit_url: 'order/tcorder/edit',
                    del_url: 'order/tcorder/del',
                    multi_url: 'order/tcorder/multi',
                    table: 'tcorder'
                }
            });


            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'),visible:false},
                        {field: 'uid', title: __('uid')},
                        {field: 'tcid', title: __('tcid')},
                        {field: 'price', title: __('price'),operate:false},
                        {field: 'price_d', title: __('price_d'),operate:false},
                        {field: 'days', title: __('days'),operate:false},
                        {field: 'days_d', title: __('days_d'),operate:false},
                        {field: 'money', title: __('money'),operate:false},
                        {field: 'duetime', title: __('duetime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                        {field: 'createtime', title: __('createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                        {field: 'updatetime', title: __('updatetime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                        {field: 'operate', title: __('Operate'), table: table,
                            events: Table.api.events.operate,
                            formatter: Table.api.formatter.operate}
                    ]
                ]
            });


            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});